#include<stdio.h>

#include "07_bst_lib.h"

// 二叉查找树 查找 | 递归

int main(){
    //创建二叉树
    struct TreeNode* root=NULL;

    // 用户输入数据: 5 3 7 2 4 6 8 /
    printf("Pls input some int, end with /\n");
    int num;
    while (scanf("%d", &num) == 1 ){
        root = insert(root, num);
    }

    // 打印结果
    printTree(root, 0, "");
    inOrder(root);
    printf("\n");

    // 吃掉一个换行符
    getchar();

    //2.输入想查找的值
    printf("Pls input one int you want to search > "); // 5
    int key;
    scanf("%d", &key);
    printf("search %d in the tree: %s\n", key,  
        //search(root, key)   //递归法
        search2(root, key)  //迭代法
        ==NULL?"F":"T" );

    // 释放内存
    freeTree(root);

    return 0;
}
